package jp.aist.gtrc.plus.admission.EDF;

import java.util.*;

public class StressTest {
   public static int numOfCPUs = 16;

   public static void main(String[] args) {
      long st = System.currentTimeMillis();
      Set<CPU> cpus = new HashSet<CPU>();
      for (int i=0; i < numOfCPUs; i++) {
         cpus.add(new CPU(i));  
      }     

      EDFAdmission admission = new EDFAdmission(); 

      ArrayList<JobArray> jobArrays = new ArrayList<JobArray>();
      for (int i=0; i < 100; i++) {
         jobArrays.add(new JobArray(""+i,200,1,(i+1)*13));
      }
      jobArrays.add(new JobArray("999",1,1000,2700));

      System.out.println(admission.test(cpus,getJobs(jobArrays)));  
      long et = System.currentTimeMillis();
      System.out.println("Time spent " + (et-st) + " ms.");
   }

   public static Collection<Job> getJobs(Collection<JobArray> jobArrays) {
      int id = 0;
      ArrayList<Job> jobs = new ArrayList<Job>();
      for (JobArray jobArray : jobArrays) {
         for (int i=0; i < jobArray.numOfJobs; i++) {
            Job job = new Job(id,jobArray.name+"/"+i,jobArray.exeTime,jobArray.deadline);
            jobs.add(job);
            id++;
         }
      }
      System.out.println("There are " + jobs.size() + " total jobs");
      return jobs;
   }



}
